package com.linkgap.cloud.repo;

import com.linkgap.cloud.entity.Student;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface StudentRepo extends JpaRepository<Student, Long> {


    //jpa 规范命名
    List<Student> findAllByNameContains(String name);

    List<Student> findAllByName(String name);

    List<Student> findAllByClazzId(Long clazzId);

    List<Student> findAllByClazzIdIn(List<Long> clzIdList);


    //jql
//    @Query("select s.name from Student s where s.name like ?1 and s.cnTeacher = ?2")
//    List<String> abc(String name, String cnTeacher);

    //sql
    @Query(nativeQuery = true, value = "select s.* from tb_student s where s.name LIKE ?1")
    List<Student> scd(String name);

//    @Query("select distinct s from Student s " +
//            "where upper(s.name) like upper(concat('%', ?1, '%')) and upper(s.cnTeacher) = upper(?2) " +
//            "order by s.cnTeacher")
//    List<Student> findDistinctByNameContainingIgnoreCaseAndCnTeacherIgnoreCaseOrderByCnTeacherAsc(@NonNull String name, String cnTeacher, Sort sort);

//    List<Student> findAllByNameContainsAndCnTeacherEquals(String name, String teacherName);

}
